import java.util.Scanner;
import java.util.concurrent.ForkJoinPool;
public class Study14 {
        /* 求素数的三大算法*/

        // 算法 —— ： 暴力遍历
        public static void main1 (String[] args) {
            Scanner scanner = new Scanner (System.in);
            if(scanner.hasNextInt()) {
                int n = scanner.nextInt();
                int count = 0;
                for (int i = 2; i <= n; i++) {
                    int sign = 1; // 用于标记是否是素数
                    for (int j = 2; j < i; j++) {
                        if (i % j == 0 ) {
                            sign = 0;
                            break;
                        }
                    }
                    if (sign == 1) {
                        System.out.print(i+"\t");
                        count++;
                        if(count % 5 == 0) {
                            System.out.println();
                        } // 2,3,5,7,11,13,17,19,23,29,31,37,41,43,53,59,61,67,71,73,79,83,89,97。
                    }
                }
            }
            scanner.close(); // 关闭 IO 流
        }


        // 算法 二: 折半范围遍历
        public static void main2 (String[] args) {
            Scanner scanner = new Scanner (System.in);
            int count = 0;
            if(scanner.hasNextInt()) {
                int n = scanner.nextInt();
                for (int i = 2; i <= n; i++) {
                    int sign = 1;
                    for (int j = 2; j <= i/2 ; j++) {
                        if(i % j == 0) {
                            sign = 0;
                            break;
                        }
                    }
                    if(sign == 1) {
                        System.out.print(i+"\t");
                        count++;
                        if(count % 5 == 0) {
                            System.out.println();
                        }
                    }

                }
            }
            scanner.close(); // 关闭 IO流
        }


        // 算法三.根号范围遍历
        public static void main (String[] args) {
            Scanner scanner = new Scanner (System.in);
            int count = 0;
            if(scanner.hasNextInt()) {
                int n = scanner.nextInt();
                for (int i = 2; i <= n; i++) {
                    int sign = 1;
                    for (int j = 2; j <= (int)Math.sqrt(i) ; j++) { // sqrt求数值的根号值，类型是 double 所以我们可以强转一下为 Int 类型
                        if(i % j == 0) {                            // 当然也可以不，让它自行强转类型
                            sign = 0;
                            break;
                        }

                    }
                    if(sign == 1) {
                        System.out.print(i+"\t");
                        count++;
                        if(count % 5 == 0) {
                            System.out.println("");
                        }
                    }

                }
            }

            scanner.close(); // 关闭IO 流

        }
}
